#include #ifdef __AVR__ #include #endif #define PIN 8 // data pin (RGB led) #define NUMPIXELS 1 // rumber of led Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); // this is a function from the lib to declare pin num and num of LEDs and the order of LEDs GRB or RGB and the frequency #define DELAYVAL 500 // 1/2 sec delay const int analogInPin = A0; // declare sensors pins const int analogInPin1 = A1; const int analogInPin2 = A2; const int analogInPin3 = A3; int sensorValue25 = 0; int sensorValue50 = 0; int sensorValue75 = 0; int sensorValue100 = 0; void setup() { #if defined(__AVR_ATtiny44__) && (F_CPU == 8000000) // attiny typ and CPU f clock_prescale_set(clock_div_1); #endif pixels.begin(); // start pixels.clear(); // clear read more } void loop() { sensorValue25 = analogRead(analogInPin); //read and save the sensor values in sensorValueXX sensorValue50 = analogRead(analogInPin1); sensorValue75 = analogRead(analogInPin2); sensorValue100 = analogRead(analogInPin3); //100% full if ( sensorValue100 > 500) { pixels.setPixelColor(0, pixels.Color(0, 0, 255)); //pixels.setPixelColor(led num, pixels.Color(R, G, B)); to set the led color pixels.show(); // to show the led color } //75% left else if (( sensorValue100 < 500) && ( sensorValue75 > 500)) { pixels.setPixelColor(0, pixels.Color(0, 255, 0)); pixels.show(); delay(500); } //50% left else if (( sensorValue100 < 500) && ( sensorValue75 < 500) && ( sensorValue50 > 500)) { pixels.setPixelColor(0, pixels.Color(255,255,0)); pixels.show(); delay(500); } //25% left else if (( sensorValue100 < 500) && ( sensorValue75 < 500) && ( sensorValue50 < 500) && ( sensorValue25 > 500)) { pixels.setPixelColor(0, pixels.Color(255,80,0)); pixels.show(); delay(500); } //NO water left else { pixels.setPixelColor(0, pixels.Color(255, 0, 0)); pixels.show(); delay(500); pixels.setPixelColor(0, pixels.Color(0, 0, 0)); pixels.show(); delay(500); } }